﻿// Necroz project team © <2015> <ArchLord2EMU>
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Author:Sagara
// Date:2015-09-24-21:57

using AL2Game.Interfaces;
using ArchLord2Commons.Enums;
using ArchLord2Commons.IoC;
using ArchLord2Commons.Network;
using ArchLord2Commons.Utils;

namespace AL2Game.Network.Frames.Recv
{
    class RfCreateCharacter : AALNetFrame
    {
        private byte _fraction;
        private byte _gender;
        private byte _class;
        private byte _race;

        private int _unk;

        private string _name;

        private byte[] _characterData;
        private byte[] _unk2;
        public override bool ProcessRead()
        {
            _unk = GetInt8(); //always 2?

            _race = GetInt8();

            _gender = GetInt8(); 
            _class = GetInt8();

            _name = GetFixedString(25);

            _unk2 = GetBytes(7);

            _characterData = GetBytes(14);

            _fraction = Extensions.GetFractionByRace((ERace) _race);

            return true;
        }

        public override void PassToEngine(AALClient receiver)
        {
            Global.GetMember<ILobbyService>().CreateCharacter((Al2Connection) receiver, _fraction, _gender, _class, _race, _name, _characterData);
        }
    }
}

//c513 00 01 02 02 4d00690073007400650072006b006100720079007a00690000 0030ec5e00369a 350003001a040808ef0b3f34d80f - female
//c513 01 02 01 01 4d006900730074006500720068006100720076006500720000 0010efa101369a 640002004c0434081c0c50390410 - male crunn